package CollectionDemo.ListDemo;

import java.util.*;

public class Traverse {
    public static void main(String[] args) {
        List<Object> list = new ArrayList<>();
        list.add(1);
        list.add("james");
        list.add(36);
        list.add("KD");
        System.out.println(list);
//      利用迭代器Iterator
        Iterator it = list.iterator();
        while(it.hasNext()){
            System.out.print(it.next() + " ");
        }
        System.out.println();
//      利用foreach
        for (Object obj:list) {
            System.out.print(obj + " ");
        }
        System.out.println();
        Set<Object> set = new TreeSet<>();
        set.containsAll(list);
        System.out.println(set);
    }
}
